package com.ph.demo.ThreadPool;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by peng on 2019/4/15.
 */
public class ExtThreadPool implements Runnable {
    @Override
    public void run() {

        System.out.println("正在执行");

    }

    public static void main(String[] args) {

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<Runnable>()){

            @Override
            protected void beforeExecute(Thread t, Runnable r){

                System.out.println("任务执行前");
            }

            @Override
            protected void terminated() {
                System.out.println("执行结束");
            }
        };

        threadPoolExecutor.submit(new ExtThreadPool());

        threadPoolExecutor.shutdown();

    }


}
